﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UL360SurveyService.Models
{
    public class SmtpSendError
    {
        public string MailAddress { get; set; }
        public string Person { get; set; }
        public string SmtpStatusCode { get; set; }
        public string ExceptionMessage { get; set; }
        public string InnerExceptionMessage { get; set; }

        public static string ToString(List<SmtpSendError> errors)
        {
            return string.Join("\n", errors.Select(e => string.Format("Namn: {0}, E-post: {1}, SMTP Statuskod: {2}, Felmeddelande: {3}, Inre felmeddelande {4}", 
                e.Person, e.MailAddress, e.SmtpStatusCode, e.ExceptionMessage, e.InnerExceptionMessage)).ToArray());
        }

        public static string AllPersons(List<SmtpSendError> errors)
        {
            return string.Join("\n", errors.Select(e => string.Format("Namn: {0}, E-post: {1}",
                e.Person, e.MailAddress)).ToArray());
        }

        public override string ToString()
        {
            string message = string.Format("Person: {0}\n", Person);
            message += string.Format("Email: {0}\n", MailAddress);
            message += string.Format("SMTP Error code: {0}\n", SmtpStatusCode);
            message += string.Format("Exception: {0}\n", ExceptionMessage);
            message += string.Format("InnerException: {0}\n", InnerExceptionMessage);

            return message;
        }
    }
}
